package com.central.scheduler.master.utils;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * @author Tindy
 * @date 2021/12/20
 * @describe
 */
public class SwitchTaskUtils {
    private static ScriptEngineManager manager;
    private static ScriptEngine engine;

    static {
        manager = new ScriptEngineManager();
        engine = manager.getEngineByName("js");
    }

    public static boolean evaluate(String expression) throws ScriptException {
        Object result = engine.eval(expression);
        return (Boolean) result;
    }

}